package com.cloudsigns.factorymanager2.project.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.project.activity.CompletionOfEvaluationActivity;
import com.cloudsigns.factorymanager2.project.activity.ProductionDailyFeedbackActivity;
import com.cloudsigns.factorymanager2.project.activity.QualityInspectionOrderActivity;
import com.cloudsigns.factorymanager2.project.bean.ProductionDailyFeedbackBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by tony on 2017/12/19.
 */

public class TableContentAdapter extends BaseAdapter {
    private Context context;
    private List<String> mListData = new ArrayList<>();
    private String tag = "";


    public TableContentAdapter(Context context, String tag) {
        this.context = context;
        this.tag = tag;
    }

    public void setData(List<String> list) {
        this.mListData.clear();
        if (null != list) {
            this.mListData.addAll(list);
        }

    }

    @Override
    public int getCount() {
        return mListData.size();
    }

    @Override
    public Object getItem(int position) {
        return mListData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_table_content_list, null);
//            holder.rl_item_data_1 = (RelativeLayout) convertView.findViewById(R.id.rl_item_data_1);
//            holder.img_return = convertView.findViewById(R.id.img_return);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

//       /*异常反馈*/
//        if (tag.equals("ProductStatusTableActivity")) {
//            holder.img_return.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View view) {
//                   /*生产日反馈*/
//                    Intent intent = new Intent(context, ProductionDailyFeedbackActivity.class);
//                    context.startActivity(intent);
//                }
//            });
//
//        } else if (tag.equals("ProductionScheduleActivity")) { //生产进度表
//            holder.img_return.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View view) {
//                   /*产品质检单*/
//                    Intent intent = new Intent(context, QualityInspectionOrderActivity.class);
//                    context.startActivity(intent);
//                }
//            });
//        } else if (tag.equals("EngineeringInstallationScheduleTableActivity")) { //工程安装进度表
//            holder.img_return.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View view) {
//                   /*竣工评价*/
//                    Intent intent = new Intent(context, CompletionOfEvaluationActivity.class);
//                    context.startActivity(intent);
//                }
//            });
//        }
//
//
//        holder.rl_item_data_1.setOnClickListener(new View.OnClickListener() {
//
//            @Override
//            public void onClick(View view) {
////                Intent intent = new Intent(context, com.cloudsigns.factorymanager2.ProductQualitySheet.class);
////                context.startActivity(intent);
//            }
//        });

        return convertView;
    }

    class ViewHolder {
        RelativeLayout rl_item_data_1;
        ImageView img_return;
    }
}
